/*
 * @Description: 模拟登陆工具类
 * @Author: tao.xie
 * @Date: 2019-04-02 11:27:04
 * @Last Modified by: yingying.fan
 * @Last Modified time: 2019-05-13 11:35:43
 */
import md5 from 'js-md5'
import ajaxAsync from 'vue-xiaobu-utils'
import { setUserInfo } from './UserBeanUtils'

const TestInVue = false

const PHONE_NO = '17706518520'
const PWD = '654321'
// const PHONE_NO = '18950892814'
// const PWD = 'hong1234'
// const PHONE_NO = '15700064942'
// const PWD = 'qwerty'
// const PHONE_NO = '15257178826'
// const PWD = '123456!'

export default async function testLogin() {
  // localStorage.setItem('XIAOBUSESSION', 'K7YXVILOBHENA7CREVWFAFZD7RTFHN0F')
  if (!window.prodInApp && TestInVue) {
    let pwd = md5(PWD)
    let json = {
      USERNAME: PHONE_NO,
      PASSWORD_MD5: pwd,
      MOBILE_MODEL: 1,
      CID: 'db92091a0a7057df248fe909d754e4e0',
      MOBILE_VERSION: 'HWPRA-H;PRA-AL00;7.0;NNet:7;P:2',
      APP_VERSION: '1.0.0'
    }
    try {
      let rs = await ajaxAsync('/user/login', json)
      // localStorage.setItem('XIAOBUSESSION', rs.SESSION_ID)
      rs.PHONE = PHONE_NO
      rs.IS_LOGIN = 1
      setUserInfo(rs)
    } catch (err) {}
  }
}
